#pragma once
#include <functional>
#include "log.hpp"
class task
{
public:
    // 等价于typedef
    using callBack_t = function<void(int, string, uint16_t)>;
    task(int sock,
         string ip,
         uint16_t port,
         callBack_t func)
        : sock_(sock),ip_(ip), port_(port), func_(func)
    {
    }

    ~task(){}
    
    void operator()()
    {
        logMessage(DEBUG,"线程[%p],处理[%s:%d]的请求开始了",pthread_self(),ip_.c_str(),port_);
        func_(sock_,ip_,port_);
        logMessage(DEBUG,"线程[%p],处理[%s:%d]的请求结束了",pthread_self(),ip_.c_str(),port_);
    }

private:
    int sock_;
    string ip_;
    uint16_t port_;
    callBack_t func_;
};